<%@page import="com.sdry.entity.permission.UpmsStaffRole"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:include page="../../common.jsp"></jsp:include>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>角色信息</title>
 <%
 	 	UpmsStaffRole use = (UpmsStaffRole)session.getAttribute("user");
  	 	Long staffId = null;
  	 	if(use != null){
  	 		staffId = use.getUpmsStaff().getStaffId();
  	 	}
	%>
<script type="text/javascript">
$(function () {

	//初始化提示框的位置：top-center，bottom-left，bottom-right
    toastr.options.positionClass = 'toast-top-center';
    $('#pass').change(function () {
    	$("#pass2").val("");
    });
  	//jQuery，既阻止默认行为又停止冒泡  导入按钮
    $(".submit").on('click',function(){
    	    return false;//当然 也阻止了事件本身
    });

});

//表单提交
function save() {
    var bootstrapValidator = $("#fm").data('bootstrapValidator');  
    //开启验证
    bootstrapValidator.validate();  
    if (bootstrapValidator.isValid()){
		var url = "${pageContext.request.contextPath }/upmsStaff/update.do";
		var title = "修改"; 
	    $.post(url, $("#fm").serialize(), function(data) {
			if (data == 1) {
				toastr.success(title+'成功');
				$("#fm")[0].reset();
			} else {
				toastr.error(title+'失败');
			}
		});
    }else{
	    return;  
    } 
}

</script>
</head>
<body>
  		
  			<div class="modal-body" style="position: absolute;margin: auto;max-width: 500px;max-height:500px;top: 1%;left: 1%;right: 1%;bottom: 1%;">
       		<form id="fm" class="form-horizontal">
       			<div class="form-group">
					<label class="col-sm-2 control-label">密码:</label>
					<div class="col-sm-8"> 
						<input type="password" name="pass" id="pass" class="col-xs-12 col-sm-4 form-control"/>
	        			<input type="hidden" name="staffId" value="<%=staffId%>">
	        		</div>
				</div>
	        	<div class="form-group">
					<label class="col-sm-2 control-label">确认密码:</label>
					<div class="col-sm-8"> 
						<input type="password" name="pass2" id="pass2" class="col-xs-12 col-sm-4 form-control"/>
					</div>
				</div>
	        	<div class="form-group">
					<div class="col-sm-3 col-sm-offset-5" style="margin-top: 5%;"> 
					    <button type="submit" class="btn btn-primary submit" onclick="save()">保存</button>
					</div>
				</div>
     		</form>
   		</div>
		
    
    
      
	
	<script type="text/javascript">
	$(function() {
		$("#fm").bootstrapValidator({
			feedbackIcons : {
				valid : 'glyphicon glyphicon-ok',
				invalid : 'glyphicon glyphicon-remove',
				validating : 'glyphicon glyphicon-refresh'
			},
			fields : {
				pass : {
					validators : {
						notEmpty : {
							message : '密码不能为空'
						}, 
					}
				}, 
				
				pass2 : {
					validators : {
						notEmpty : {
							message : '密码不能为空'
						}, 
						callback: {
                            message: '与密码不等，请重新确认密码',
                            callback:function(value, validator){
                                var flg = false;
                                var ma = $.trim($('#pass').val());
								if(ma == null || ma == "" || ma == value){
									flg = true;
								}
                                return flg;
                            }
                        },
					}
				},
			},
		});
	});
	</script>
</body>
</html>